;^CsOEQ[@Tv
#include "hspda.as"
onexit *owari

title "^Cvœǂ߂lRoY[J"
mmload "sound/ok.wav",1
mmload "sound/miss.wav",2
mmload "sound/page.wav",3
mmload "sound/bazuka.wav",4
mmload "sound/okane.wav",5
randomize
point=0:type_kazu =0
//w|Cg̉Zp
tasu_point =0
//Z\EłƂ̃vXl /10\p
ginou =10
//zmہi{^ʒuj0~55
dim wa_sw,56
//zmہiQOȏ̎j߂ɑ啝ɊmہAȌ̂݁ioȂj
sdim wakeru_array,300,15
sdim wakeru_array2,300,15
//PbڃI[vij
wa_sw(0)=1

//zE|Cg̕ۑ厖 ꂱexe炻̂܂܃f[^ԃRs[˂H
//t@CEEE
vload_start "save_data"
//͓ǂ߂Ȃ̂ ϐstatŕ
if(stat=0){
  vload_get wa_sw
  vload_get point
  vload_get ginou
  vload_get tasu_point
}
vload_end

//I
*TOP
screen 0,800,700
mouse_no = 1
cls
color 230,230,230:boxf
//wiG
pos rnd(ginfo(10)),rnd(ginfo(11))
picload "picture/title.jpg",1
pos rnd(ginfo(10)),rnd(ginfo(11))
picload "picture/title2.jpg",1

color 15,12,12
pos 20,5
mes " "+point
objmode 2
font "MS UI Gothic", 15, 1
//{^쐬{^i˂POOj
//objsize 300, 20
if(point>=100 + (tasu_point * tasu_point)& wa_sw(55)= 0){
	pos 180,5
	color 200,200,245
	boxf 170,5,490,25
	color 0,0,0
	mes "Enter :̘bI[vI(" + (100 + (tasu_point * tasu_point)) +")"
}
font "",20,4
pos 520,5
mes "Z\F"+ ginou/10


//objsize 120, 20
notesel buf2
noteload "coment/SRg.txt"

//z̔Ń{^쐬
  repeat length(wa_sw)
  if(wa_sw(cnt)>=1){
	//ŏIbWႤ
	if(cnt!=55){dai_x =20+(cnt/11*150):dai_y = 35+(cnt\11*60)}
	else{dai_x =640:dai_y = 5}
	pos dai_x,dai_y 
	
	color 200,200,245
	boxf dai_x-5,dai_y,dai_x+120,dai_y+20 

	color 0,0,0
	//ifœěƂ߂ĂƒȂ肷̂ło
	mozi_code1="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	mozi_code2="F1 F2 F3 F4 F5 F6 F7 F8 F9 F10"
	//L[{[hőIłK@A~ZɑΉ
	if(cnt<36):key_mozi= strmid(mozi_code1,0+cnt,1)
	if(cnt>=36 & cnt<46){
		key_mozi= strmid(mozi_code1,25+(cnt\35),1)
		key_mozi = "ݷ"+key_mozi
	}
	if(cnt>=46):key_mozi= strmid(mozi_code2,0+((cnt-46)*3),3)
	if(cnt=55):key_mozi ="Speace"
	//
	font "MS UI Gothic", 15, 1
	if(cnt!=55){mes key_mozi + " :"+"" + (cnt+1)+ "b"}
	else{mes key_mozi + " :"+"ŏIb"}

	//NARg
	if(wa_sw(cnt)>1){
	font msgothic, 13, 0
	pos dai_x-15,dai_y+25
	
	noteget comentS,cnt
	i=0
	repeat
	  getstr clear_coment,comentS,i,','
	  if strsize=0:break
	  mes clear_coment
	  i=i+strsize
	loop
	}
  }
  loop
onkey *jump
onclick  gosub *mouse_key
stop


//}EXł悤
*mouse_key
	M_x =mousex:M_y =mousey
*nise_mouse
//{^ǉ̈	
if(point>=100 + (tasu_point * tasu_point) & wa_sw(55)= 0){
	if(150 <M_x & 490 >M_x){
		if(5 <M_y & 30 >M_y){
			if(mouse_no =1):goto *open
		}
	}
  }

//{^̑傫
obj_x=120:obj_y=20

  repeat length(wa_sw)
  if(wa_sw(cnt)>=1){
	//ꂼ̃{^蔻  {^W𒆐SƂĐݒuA
	if(cnt!=55){
	haba_x1 = 20+(cnt/11*150)
	haba_x2 = 20+(cnt/11*150) + obj_x
	haba_y1 = 35+(cnt\11*60)
	haba_y2 = 35+(cnt\11*60) + obj_y
	}
	else{
	//ŏIbWႤ
	haba_x1 = 640
	haba_x2 = 640 + obj_x
	haba_y1 = 5
	haba_y2 = 5 + obj_y
	}

	if(haba_x1 <M_x & haba_x2 >M_x){
		if(haba_y1 <M_y & haba_y2 >M_y){
			if(mouse_no =1){bottan_no =cnt:goto *sentaku}
		}
	}
  }
  loop
//stop	
return

/*
   48`57    : [0]`[9]iCL[{[hj
   65`90    : [A]`[Z]
   96`105    : [0]`[9]ieL[
   112`121    : t@NVL[ [F1]`[F10]
   32    : Xy[XL[
   13    : [ENTER]
*/
//L[{[h荞
*jump
  key_sw =65
  //xP`26܂
  repeat
  if(wparam==key_sw){
	if(wa_sw(cnt)>=1){bottan_no =cnt:goto *sentaku}
  }
  key_sw++
  if(key_sw > 90):break
  loop
  
  //x27`36܂
  key_sw =48
  repeat
  if(wparam==key_sw){
	if(wa_sw(cnt+26)>=1){bottan_no =cnt+26:goto *sentaku}
  }
  key_sw++
  if(key_sw > 57):break
  loop
  
  key_sw =96
  //x37`46܂
  repeat
  if(wparam==key_sw){
	if(wa_sw(cnt+36)>=1){bottan_no =cnt+36:goto *sentaku}
  }
  key_sw++
  if(key_sw > 105):break
  loop
  
   //x47`55܂
  key_sw =112
  repeat
  if(wparam==key_sw){
	if(wa_sw(cnt+46)>=1){bottan_no =cnt+46:goto *sentaku}
  }
  key_sw++
  if(key_sw > 121):break
  loop

  //G^[A
  if(wparam==13 & point>=100 + (tasu_point * tasu_point) &wa_sw(55)= 0):goto *open
  //Xy[XL[AŏIb
  if(wparam==32 & wa_sw(55)>=1){bottan_no =55:goto *sentaku}
stop

//Œǉb
*open
	mmplay 5
	point -= 100 + (tasu_point * tasu_point)
	tasu_point++
	//SĂ΍ŏIbǉ
	all_wa=0
	repeat 55
		if(wa_sw(cnt) =0):all_wa=1
	loop
	//ŏIbI[vAޔ
	if(all_wa=0){wa_sw(55)=1:goto *TOP}
	
	repeat
		AAA= rnd(55)
		if(wa_sw(AAA) = 0){
		  wa_sw(AAA) =1
		  break
		}
	loop
goto *TOP

*sentaku
//ݖ萔
clear_no = 0
//eLXg肩ǂݍ
notesel buf
noteload "text/"+bottan_no+".txt"
title "" +(bottan_no +1)+ "b"
cls

*greset
	;̏
	cursor=0:wakeru_size= 0:genzai_size=0
	//^CvɃ}EXI𖳌ɂ邽߂
	mouse_no = 0
	//菇Ԃǂލs߂
	//m[g̍s
	m=clear_no
	//^CvE{ꕶEwi摜ǂݍށA
	noteget mondai,m
	noteget mondai2,m+1
	noteget pict,m+2
	clear_no+=3
	//S萔P̖̍siAt@xbg{{{摜j
	if(clear_no > notemax):goto *game_clear 
;	
	//͕ĕ\
	if(strlen(mondai) > 20){
		genzai_size=0
		//z̑傫izȂ̂Ŏ̕KvAj
		wakeru_size = strlen(mondai) / 20
		//QO̔{Ɖł̂ăn}悤Ȃ̂Ō炷EEE
		if(strlen(mondai) \ 20 = 0):wakeru_size--
		//O琔̂łPグKvH
		wakeru_size++
		//strlen(mondai) - strlen(mondai) \ 20)/ 20
		//20Ƃɕ̂Ă
		repeat wakeru_size
		wakeru_array(cnt) =strmid(mondai,0+(20*cnt),20)
		wakeru_array2(cnt) =strmid(mondai2,0+(20*cnt),20)
		loop
		//Pԏ߂mondai㏑
		mondai=wakeru_array(0)
		mondai2=wakeru_array2(0)
	}
;
	typemode=0
//obt@
	redraw 0
	buffer 2,320,320,0
	picload "picture/"+ pict,0
	pic_x=ginfo_winx
	pic_y=ginfo_winy
	screen 0,640,480
	gmode 0,pic_x,pic_y
	redraw 1
	
	onkey gosub *typein
*main
	;Q[C
	redraw 0
	color 192,192,192:boxf
	pos ginfo(10)/2-pic_x/2,ginfo(11)/2-pic_y/2
	gcopy 2,0,0,pic_x,pic_y
		
	font msgothic,16
	color 0,0,0
	pos 80,20:mes ":"+point
	font msgothic,30,1
	color 0,120,160
	//strlen@̒𓾂邪A{͂QoCgȂ̂*2
	pos 340 - (strlen(mondai2)*5),20:mes mondai2
	pos 340 - (strlen(mondai) *5 ),60:mes mondai
	pos 340 - (strlen(mondai) *5 ),60:color 255,0,0:mes strmid(mondai,0,cursor)
	redraw 1
	await 50
	if typemode>0:onkey 0:goto *greset
	goto *main
	
*gameover
	onkey 0
	dialog "Q[I[o["
	end
*typein
	;L[̏
	a=peek(mondai,cursor)
	//ESCœrłʂ
	if(iparam =27){typemode=1:goto *game_clear}
	
	if a!=iparam:goto *typemiss
	point+=ginou
	//PłƂɓ邨Av
	type_kazu++
	if(type_kazu =7){ginou++:type_kazu=0}
	mmplay 1
	len=strlen(mondai)
	
	cursor=cursor+1:if cursor<len:return
	genzai_size++
	if(wakeru_size<=genzai_size){mmplay 3:typemode=1}//NA
	else{//Rł܂cĂ
	  cursor=0
	  mondai = wakeru_array(genzai_size)
	  mondai2 = wakeru_array2(genzai_size)
	}
	return
*typemiss
	;~X^b`
	mmplay 2
	return
*game_clear
	//YL[A݂ȌeioY[Jj̉
	onkey 0
	mmplay 4
	//NAƂQɁA
	wa_sw(bottan_no)=2
	goto *TOP

*owari
	vsave "save_data"
	end